<template>
    <Layout class="platform">
        <Header style="height: 50px;">
            <platform-header></platform-header>
        </Header>
        <Layout>
            <Sider>
                <sider-page></sider-page>
            </Sider>
            <Content>
                <router-view></router-view>
            </Content>
        </Layout>
    </Layout>
</template>
<script>
    import PlatformHeader from './Platform/PlatformHeader';
    import SiderPage from './Platform/SiderPage';

    var mysql = require('mysql');

    export default {
        name: "platform",
        components: {
            PlatformHeader,
            SiderPage
        },
        data() {
            return {}
        },
        methods: {
            closeWindow() {
                // 连接数据库的配置
                var connection = mysql.createConnection({
                    // 主机名称，一般是本机
                    host: 'localhost',
                    // 数据库的端口号，如果不设置，默认是3306
                    port: 3306,
                    // 创建数据库时设置用户名
                    user: 'root',
                    // 创建数据库时设置的密码
                    password: '123456',
                    // 创建的数据库
                    database: 'gnerv-business'
                });
                // 与数据库建立连接
                connection.connect();
                // 查询数据库
                connection.query('SELECT * from user', function (err, result) {
                    if (err) {
                        console.log(err.message());
                        return;
                    }

                    for (let obj of result) {
                        console.log('The solution is: ', Object.keys(obj))
                    }

                    ;
                });
                // 关闭连接
                connection.end();
            }
        },
        created : function() {
            this.closeWindow();
        }
    }
</script>
<style scoped>

</style>

